{% extends 'base.html' %}
{% load widget_tweaks %}


{% block html_title %}
    Profile Modify
{% endblock %}


{% block html_body_nav_ol %}

    <li class="breadcrumb-item"><a href="{% url 'home' %}">Home</a></li>
    <li class="breadcrumb-item"><a href="{% url 'review:index' %}">Review</a></li>
    <li class="breadcrumb-item"><a href="{% url 'review:profile-list' %}">Profile</a></li>
    <li class="breadcrumb-item active" aria-current="page">Edit</li>

{% endblock %}


{% block html_body %}

    <form method="post">{% csrf_token %}
        {{ form.non_field_errors }}

        <div class="row">

            <div class="col-8">
                <div class="mb-3">
                    {{ form.review_description_template.errors }}
                    <label for="id_review_description_template">Description Template:</label>
                    <textarea class="form-control" name="review_description_template" cols="80" rows="12"
                              maxlength="100"
                              id="id_review_description_template">{{ form.review_description.value }}</textarea>
                </div>

                <div class="mb-3">
                    {{ form.review_testing_done.errors }}
                    <label for="id_review_testing_done">Testing Done Template:</label>
                    <textarea class="form-control" name="review_testing_done" cols="80" rows="12" maxlength="100"
                              id="id_review_testing_done">{{ form.review_testing_done.value }}</textarea>
                </div>
            </div>

            <div class="col-4">

                <div class="mb-3">
                    {{ form.profile_name.errors }}
                    <label class="form-label" for="id_profile_name">Profile name:</label><br/>
                    {% render_field form.profile_name class+='form-control' %}
{#                    <input class="form-control" name="profile_name" id="id_profile_name" maxlength="100"#}
{#                           value="{{ form.profile_name.value }}">#}
                </div>

                <div class="mb-3">
                    {{ form.review_repository.errors }}
                    <label for="id_review_repository">Repository:</label><br>
                    {% render_field form.review_repository %}
                </div>

                <div class="mb-3">
                    {{ form.review_branch.errors }}
                    <label class="form-label" for="id_review_branch">Branch:</label><br/>
                    {% render_field form.review_branch class+='form-control' %}
                </div>

                <div class="mb-3">
                    {{ form.review_target_people.errors }}
                    <label class="form-label" for="id_review_target_people">Target people:</label><br/>
                    {% render_field form.review_target_people multiple='multiple' %}
                </div>

                <div class="mb-3">
                    {{ form.review_target_groups.errors }}
                    <label class="form-label" for="id_review_target_groups">Target groups:</label><br/>
                    {% render_field form.review_target_groups multiple='multiple' %}
                </div>
                <div class="mt-5">
                    <input class="btn btn-lg btn-info" type="submit" value="Save">
                </div>
            </div>

        </div>
        {{ form.user.errors }}
        <input type="hidden" name="user" value="{{ form.user.value }}" id="id_user">
    </form>

{% endblock %}

{% block javascript %}


    <script type="text/javascript">

        const groups_value = "{{ form.review_target_groups.value }}".split(",")
        const people_value = "{{ form.review_target_people.value }}".split(",")
        const repository_value = "{{ form.review_repository.value }}".split(",")

        $(document).ready(function () {
            $('#id_review_target_groups').multiselect('select', groups_value);
            $('#id_review_target_people').multiselect('select', people_value);
            $('#id_review_repository').multiselect('select', repository_value);
        });

    </script>


{% endblock %}